﻿/// <summary>
/// https://leetcode-cn.com/problems/jump-game-ii/
/// </summary>
public class Solution
{
    public int Jump(int[] nums)
    {
        int result = 0;
        int last = 0;
        int next = 0;
        for (int i = 0; i < nums.Length - 1; i++)
        {
            next = Math.Max(next, nums[i] + i);
            if (i == last)
            {
                last = next;
                result++;
            }
        }
        return result;
    }
}